<template>
  <div class="page">
    <h1 @click="govuex">
      我是首页
    </h1>
    <h2>{{ name }}</h2>
    <h3 @click="changeCount">
      {{ countStr }}
    </h3>
    <h1 title="env">
      env: {{ envname }} api: {{ apiurl }}
    </h1>
  </div>
</template>

<script>
export default ({
  components: {},
  data() {
    return {
      name: 'Liu Yi Fei',
      apiurl: process.env.VUE_APP_BASE_API,
      envname: process.env.NODE_ENV
    }
  },
  computed: {
    countStr() {
      return 'vuex中的count: ' + this.$store.state.count
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {},
    govuex() {
      this.$router.push({
        name: 'vuex',
        params: { pathMatch: this.$route.path.split('/'), username: 'erina' }
      })
    },
    changeCount() {
      this.$store.commit('decrement', {
        id: 1,
        amount: 10
      })
    }
  }
})
</script>

<style scoped>
h1 {
  color: orange;
}
</style>
